<script setup>
import { useWorkStore } from '@/stores/work'
const workStore = useWorkStore()
// 示例作品数据
const works = workStore.works


</script>

<template>
  <div class="works-container">
    <main class="works-content">
      <!-- 标题区域 -->
      <section class="hero-section">
        <h1 class="page-title ">
          <span
            class="title-word "
            v-for="(word, index) in '我的作品'.split('')"
            :key="index"
          >
            {{ word }}
          </span>
        </h1>
        <p class="page-subtitle">探索我的创意与技术实践</p>
      </section>

      <!-- 作品网格 -->
      <div class="works-grid">
        <div
          v-for="work in works"
          :key="work.id"
          class="work-card "
          :style="{ animationDelay: `${work.id * 0.1}s` }"
        >

          <div class="work-info">
            <h3 class="work-title">{{ work.title }}</h3>
            <p class="work-description">{{ work.description }}</p>
            <div class="work-meta">

              <router-link
                :to="`/works/${work.id}`"
                class="work-link"
              >
                查看详情
                <el-icon><i-ep-ArrowRight /></el-icon>
              </router-link>
            </div>
          </div>
        </div>
      </div>

      <!-- 空状态处理 -->
      <div
        v-if="works.length === 0"
        class="empty-state"
      >
        <p>暂无作品展示</p>
      </div>

      <!-- 页脚装饰 -->
      <div class="footer-decoration ">
        <div class="decoration-line"></div>
        <div class="decoration-dot"></div>
        <div class="decoration-line"></div>
      </div>
    </main>
  </div>
</template>

<style scoped>
/* 全局容器样式 */
.works-container {
  min-height: 100vh;
  background-color: var(--bg-color);
  color: var(--text-color);
  padding-top: 80px;
  background-image: radial-gradient(circle at 10% 20%,
      rgba(95, 168, 252, 0.03) 0%,
      transparent 20%),
    radial-gradient(circle at 80% 60%,
      rgba(95, 168, 252, 0.03) 0%,
      transparent 25%);
  background-attachment: fixed;
}

/* 内容区域 */
.works-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

/* 标题区域 */
.hero-section {
  text-align: center;
  margin-bottom: 3.5rem;
  padding-bottom: 2rem;
  position: relative;
}

.hero-section::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  max-width: 1100px;
  height: 3px;
  background: linear-gradient(90deg,
      transparent,
      var(--primary-color),
      transparent);
  border-radius: 3px;
  opacity: 0;
  animation: fadeInExpand 1s ease 0.5s forwards;
  box-shadow: 0 0 10px rgba(95, 168, 252, 0.3);
}

.page-title {
  font-size: 3rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  text-align: center;
}

/* 逐字动画 */
.title-word {
  display: inline-block;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.6s ease forwards;
  background: linear-gradient(135deg, var(--primary-color), #67a8f2, #59a6ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  background-size: 200% auto;
}

/* 为每个文字添加不同的动画延迟 */
.title-word:nth-child(1) {
  animation-delay: 0.1s;
}

.title-word:nth-child(2) {
  animation-delay: 0.2s;
}

.title-word:nth-child(3) {
  animation-delay: 0.3s;
}

.title-word:nth-child(4) {
  animation-delay: 0.4s;
}

.page-subtitle {
  font-size: 1.2rem;
  color: var(--text-secondary);
  max-width: 600px;
  margin: 0 auto;
  opacity: 0;
  animation: fadeInUp 0.6s ease 0.5s forwards;
}

/* 作品网格 - 修复错行问题 */
.works-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  grid-auto-rows: 1fr;
  /* 确保每行卡片高度一致 */
  gap: 2.5rem;
  margin-bottom: 4rem;
  opacity: 0;
  animation: fadeInUp 0.8s ease 0.9s forwards;
}

/* 作品卡片 */
.work-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 2rem;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.02);
}

.work-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 40px rgba(95, 168, 252, 0.08);
  border-color: rgba(95, 168, 252, 0.3);
}

/* 作品信息 */
.work-info {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100%;
}

.work-title {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: #59a6ff;
  font-weight: 600;
  transition: color 0.3s ease;
  line-height: 1.3;
}

/* 修复描述过长导致的错行问题 */
.work-description {
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 1rem;
  flex: 1;
}

/* 作品元数据 */
.work-meta {
  display: flex;
  justify-content: flex-end;
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

/* 查看详情链接 */
.work-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s ease;
  background: rgba(95, 168, 252, 0.204);
  padding: 0.6rem 1.2rem;
  border-radius: 25px;
  border: 1px solid transparent;
  font-size: 0.95rem;
}

.work-link:hover {
  background: var(--primary-color);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(95, 168, 252, 0.3);
}

.work-link:hover el-icon {
  transform: translateX(4px);
}

.work-link el-icon {
  transition: transform 0.3s ease;
  font-size: 0.9rem;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 5rem 2rem;
  color: var(--text-secondary);
}

/* 页脚装饰样式 */
.footer-decoration {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 4rem;
  padding-bottom: 3rem;
  opacity: 0;
  animation: fadeIn 1s ease 1s forwards;
}

.decoration-line {
  height: 1px;
  width: 40px;
  background-color: var(--border-color);
}

.decoration-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--primary-color);
  margin: 0 8px;
}

/* 淡入动画 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* 淡入上移动画 */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 淡入展开动画 - 新添加 */
@keyframes fadeInExpand {
  0% {
    opacity: 0;
    width: 0;
  }

  50% {
    opacity: 0.8;
  }

  100% {
    opacity: 1;
    width: 100%;
    max-width: 1100px;
  }
}

/* 响应式设计优化 */
@media (max-width: 992px) {
  .works-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
  }
}

@media (max-width: 768px) {
  .works-content {
    padding: 1.5rem;
  }

  .page-title {
    font-size: 2.2rem;
  }

  .page-subtitle {
    font-size: 1.1rem;
  }

  .works-grid {
    grid-template-columns: 1fr;
    gap: 1.8rem;
  }

  .work-card {
    padding: 1.5rem;
  }

  .project-badge {
    top: 1rem;
    right: 1rem;
  }
}

@media (max-width: 480px) {
  .works-content {
    padding: 1rem;
  }

  .hero-section {
    margin-bottom: 2.5rem;
  }

  .page-title {
    font-size: 1.8rem;
  }

  .filter-chip {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
  }

  .work-title {
    font-size: 1.3rem;
  }

  .work-description {
    font-size: 0.95rem;
  }

  .work-link {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }
}
</style>